import request from '@/utils/request'

// eslint-disable-next-line camelcase
export const getArticles = (channel_id, timestamp) => {
  // 如果函数没有写return，
  //  它有一个默认的return值，就是undefined
  // return request({
  return request({
    url: 'v1_0/articles', // 接口地址
    method: 'GET',
    params: {
      channel_id,
      // 时间戳，请求新的推荐数据传当前的时间戳，请求历史推荐传指定的时间戳
      timestamp
    }
  })
}
// 对文章不感兴趣/不喜欢
export const unLike = (articleId) => {
  return request({
    url: '/v1_0/article/dislikes',
    method: 'POST',
    data: {
      target: articleId
    }
  })
}

// 举报文章

export const report = (articleId, typeId) => {
  return request({
    url: '/v1_0/article/reports',
    method: 'POST',
    data: {
      target: articleId,
      type: typeId
    }
  })
}
// 获取详情
export const getDetail = (articleId) => {
  return request({
    url: '/v1_0/articles/' + articleId,
    method: 'GET'

  })
}

/**
 * 取消点赞
 * @param{*} id 文章编号
 */

export const deleteLike = id => {
  return request({
    url: '/v1_0/article/likings/' + id,
    method: 'DELETE'
  })
}

/**
 * 添加点赞
 */

export const addLike = id => {
  return request({
    url: '/v1_0/article/likings',
    method: 'POST',
    data: {
      target: id
    }
  })
}

// 不喜欢
export const removeLike = id => {
  return request({
    url: '/v1_0/article/dislikes',
    method: 'POST',
    data: {
      target: id
    }
  })
}
